package service

import (
	"gin/common"
	"gin/model"
	"gin/validate"
)

func CreateSentenceNerToken(Data validate.AddSentenceNerToken) (resData model.SentenceNerToken, err error) {
	var SentenceNerTokenModel model.SentenceNerToken
	SentenceNerTokenModel.Word = Data.Word
	SentenceNerTokenModel.BeginOffset = Data.BeginOffset
	SentenceNerTokenModel.Length = Data.Length
	SentenceNerTokenModel.Type = Data.Type
	SentenceNerTokenModel.SentenceId = Data.SentenceId

	_, err = SentenceNerTokenModel.Insert()

	resData = SentenceNerTokenModel

	return
}

func FindSentenceNerToken(Param common.SelectQueryParam) (resData model.SentenceNerToken, err error) {
	var logModel model.SentenceNerToken

	resData, err = logModel.Find(Param)

	return
}

func SelectSentenceNerToken(Param common.SelectQueryParam) (total int64, resData []model.SentenceNerToken, err error) {
	var logModel model.SentenceNerToken

	total, resData, err = logModel.Select(Param)

	return
}

func UpdateSentenceNerToken(Data validate.UpdateSentenceNerToken) (resData model.SentenceNerToken, err error) {

	resData, err = resData.Update(model.SentenceNerToken{
		Id:          Data.Id,
		BeginOffset: Data.BeginOffset,
		Word:        Data.Word,
		Length:      Data.Length,
		Type:        Data.Type,
		SentenceId:  Data.SentenceId,
	})
	return
}

func DeleteSentenceNerToken(param *common.Filter) {

	var logModel model.SentenceNerToken
	logModel.DeleteByFilter(param)
	return

}
